

//支付按钮
function oncontract() {
	$("#formpay").submit();
}

$(function () {
	$('.payment table tr td img').click(function () {
		var o = $(this);
		var op = o.parent('td');
		var optb = op.parents('div.payment');
		var ops = op.prev('td.rdiaos');
		optb.find('img').removeClass('on');
		o.addClass('on');
		ops.find('input').click();
	});

	$("#formpay").submit(function () {
		$(".zhedang").show();
		$("#OrderStatusPop").show();
	});

	$("#closeNote").click(function () {
		$(".zhedang").hide();
		$("#OrderStatusPop").hide();
	});
});

function GetPayStatus(method, orderId) {
	var payUrl = "/tours/line/onlinepay/orderid/" + orderId;
	var orderUrl = "/tours/user/orderline";
	if (orderId !== "") {
		$.ajax({
			url: "/tours/line/GetPayStatus/orderid/" + orderId,
			method: "post",
			error: function (e) {
				window.location.href = payUrl;
			},
			success: function (msg) {
				if (method === "Y") {
					if (msg === "1") {
						window.location.href = orderUrl;
					} else if (msg === "0") {
						window.location.href = payUrl;
					} else {
						window.location.href = payUrl;
					}

				}
				if (method === "N") {
					if (msg === "0") {
						$("#formpay").submit();
					} else if (msg === "1") {
						alert("该订单已支付成功！");
						window.location.href = orderUrl;
					} else {
						window.location.href = payUrl;
					}
				}
			}
		});
	} else {
		window.location.href = payUrl;
	}

}